package com.education.user.mapper;


import com.education.user.pojo.SysInfoMsg;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 消息 数据层
 *
 * @author d
 * @date 2020-03-24
 */
@Repository
public interface SysInfoMsgMapper extends Mapper<SysInfoMsg> {

    @Select({
            "<script>",
                "SELECT id,m_title mTitle,m_cover mCover,information_id informationId,furls furls,create_time createTime,del_flag delFlag,m_content mContent,user_id userId,type type FROM sys_info_msg WHERE id in",
                "<foreach collection='idList' index='index' item='id' open='(' separator=',' close=')'>",
                    "#{id}",
                "</foreach>",
                "and user_id=#{userId}",
                " <when test='type!=null'> ",
                "and type=#{type}",
                " </when> ",
            "</script>"
    })
    List<SysInfoMsg> findByIds(@Param("idList") List<Integer> idList,Integer userId,Integer type);

    @Select({
            "<script>",
                "SELECT id,m_title mTitle,m_cover mCover,information_id informationId,furls furls,create_time createTime,del_flag delFlag,m_content mContent,user_id userId,type type FROM sys_info_msg WHERE id not in",
                "<foreach collection='idList' index='index' item='id' open='(' separator=',' close=')'>",
                    "#{id}",
                "</foreach>",
                "and user_id=#{userId}",
                " <when test='type!=null'> ",
                "and type=#{type}",
                " </when> ",
            "</script>"
    })
    List<SysInfoMsg> findNotByIds(@Param("idList") List<Integer> idList,Integer userId,Integer type);

    //@Select({"select class_id as classId from educationlessons.t_student  where phone = #{phone}"})
    //TStudent judgeStudent(@Param("phone") String phone);
}